Repository navigation
fix(metadata)!: a version the platform registered is never restored into a package's row, and adopt-orphans leaves the platform's record - #37640
Conversation
…red into a package's row and for adopt-orphans over the platform's record (red on base) Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…to a package's row; adopt-orphans skips the platform's record; one platform-row reader Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…listPackageBindings names a lost loader once; changeset Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…al it backs Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…atform-record-followups
…into the changelogs Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
…-orphans pin Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
📓 Docs Drift CheckThis PR changes 3 package(s): 19 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 7 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 180 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin cd169a02eca1c1bf751ba07f70997e80e6850777 && git checkout cd169a02eca1c1bf751ba07f70997e80e6850777
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 33a31dc7b083e1a25310b0323c8cc5d796c3b4b8 d96a1a97b72039e0a1ff03a582bbd2705ab5a3d5 && git checkout -B drift-repro 33a31dc7b083e1a25310b0323c8cc5d796c3b4b8 && git merge --no-ff d96a1a97b72039e0a1ff03a582bbd2705ab5a3d5
node scripts/docs-audit/affected-docs.mjs --json 33a31dc7b083e1a25310b0323c8cc5d796c3b4b8
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Contract reviewServed-tier: Read: the diff from merge-base ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
No must-fix, no should-fix.
Implemented-by: VERDICT: PASS |
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK 维护者速读
席位意见:两级审核在这个 head 上都通过,CI 全绿(唯一一次红是 CLI 包里一个与本 PR 无关的测试超时,重跑已过);剩余小问题立卡 #37656。建议批准。 席位核对 — ACCEPT · repo:objectstack#6 · head
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Review requested: this narrowing PR lands by an authorized APPROVED review or an enqueue by an approver. Records at head |
Fixes #37604
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no
skills/page teaches restoring a platform-registered version, adopting orphans over the platform's record, orlistPackageBindings维护者速读
What changes
Item 1 — a version the platform registered is never restored into a package's row. Reproduced on main first (pins red on base, readings below): after the platform withdraws its record of a skill, the name's one remaining holder is the package, a version attributed to the environment counts as that package's slot (
isVersionOf/isAddressedVersion, M1), and a rollback naming the package, or bare, answeredReverted to version 1 (package=com.acme.crm)and wrote the platform's body into the package's row. It reproduced at all three restore doors: the metadata service'srollback, and the protocol'srollbackMetaItemand restore limb ofrevertCommit(the last for a commit that names its package, asrecordPackageCommitalways writes it; that limb passes noversionOf, so it reaches this whenever the commit's version is one the platform registered).Route taken: the loud refusal,
409 RESOURCE_CONFLICT, the envelope ofrefusePlatformRecordRestore, nothing written;revertCommitlands the item infailed[]and still reverts the commit's other items. Judged on the four axes:@objectstack/metadata) that all three doors ask, rather than a per-door filter of which versions a package "wrote";restore only the package's own versionswould have meant re-defining the M1 attribution rule that history reads share, a larger change for the same outcome.The refusal lives in
refusePlatformRecordRestoreas an optional fourth argument (the version's history row, its number, and the package whose row is written). The version is judged by its history row with the one reader below: attributed to no package or to the environment, and its body carries the platform's mark and names no package. A version restored into the package-less row (the environment's own item) is left as before.Item 2 — adopt-orphans leaves the platform's own record. Reproduced on main:
reassignOrphanedMetadatarebound the platform's package-less row to the target package. It now skips a rowisPlatformRecordRowreads as the platform's record, as it skips an artifact-backed overlay; every other orphan is adopted as before.N5 — one platform-row reader.
isPlatformRecordRow(row)is now exported from@objectstack/metadata(database-loader.ts): the package column names no package (empty, or the environment's history mark) and the body carries the platform's mark and names no package.refusePlatformRecordRestore, the protocol's overlay census (protocol-diff-delete-load.ts, whose private copy is deleted — the only edit in that file) and the adoption ask it. Consequence: a package-bound row whose body keeps the mark is no longer refused by the row rule (it was refused, prescribing to name the package already named).N1 — the refusal's prescription now says re-saving a version's body as the environment's own item "holds until the platform's next registration at boot writes its record back".
N2 — new pins ride
rollbackMetaItem(named and bare) andrevertCommitwith a commit that names its package.#37187 N3 —
listPackageBindingsskips, in its row walk, a loader the list walk already lost: named once inerrors, reported once, its rows not read a second time.#37187 N6 — one doc-comment sentence in
packages/spec/src/contracts/metadata-service.ts: a primed copy answers its row's column as the registry last knew it (the column the boot priming pass wrote when it bound the row, else the column it was read with).N3 (#37423 review) — dropped.
.changeset/37013-platform-skill-own-slot.mdis no longer pending: the prereleasechore: version packages (next)(33a31dc7) compiled it intopackages/metadata/CHANGELOG.mdandpackages/metadata-protocol/CHANGELOG.mdand moved it to.changeset/pre/. The same holds for the 37130 note that N1 mentions, so N1 changes the runtime message only. A factual fix to a compiled entry belongs in a docs-only PR, not here. N4 needed nothing.Serial constraints:
protocol-save.tsis untouched;protocol-diff-delete-load.tscarries only the shared reader (an import swap and the deleted private copy);sys-metadata-repository.tscarries one call-site change.Public surface:
isPlatformRecordRow(new export) and the optional fourth argument ofrefusePlatformRecordRestore. With the two refusals, that is why this declaresClause-②: yes (narrowing), not the claim'sno.Metadata-protocol: none: no key, accepted value, code or route changes; levelpatch, BREAKING banner and ADR-0087 marker in.changeset/37604-platform-record-followups.md.Tests
packages/metadata-protocol/src/protocol.platform-mark-rollback.test.ts:rollbackMetaItemnaming the package and bare, andrevertCommitof a commit naming the package, each assertingcode: RESOURCE_CONFLICT,status: 409, the message's "the platform registered", and the rows byte-identical; plus a control that the package's own version still restores.packages/metadata-protocol/src/protocol.adopt-orphans-platform-record.test.ts: the platform's row stays unbound while the environment orphan beside it is adopted; a control that a package-less row whose body names a package is adopted.packages/metadata/src/loaders/database-loader.test.ts: the service door'srollbacknamed and bare after a realregister(..., { origin: 'platform' })+unregister(..., { origin: 'platform' }); N5 reader and refusal envelope pins; the feat(metadata): listPackageBindings reads an item's package from its stored row's package column #37187 N3 pin.Red on base (main 4e10d4b)
expected { success: true, … } to match object { code: 'RESOURCE_CONFLICT', … }; received messageReverted to version 1 (package=com.acme.crm) — type=skill, name=helper [seq=3].expected 'app.base' to be null.expected { name: 'data_explorer', … } to match object { code: 'RESOURCE_CONFLICT', … }.Ablations (fix committed first; each mutation landed via scripts/ablation-replace.mjs, rebuilt, dist preflight checked, restored to HEAD and rebuilt)
database-loader.test.ts2 failed / 498 passed; protocol files 3 failed / 9 passed (the tworollbackMetaItempins and therevertCommitpin).Suites after the merge of main (33a31dc)
@objectstack/metadataand@objectstack/metadata-protocoltypecheck: exit 0 (tree of 478efd8).@objectstack/metadatavitest: Test Files 83 passed, Tests 2814 passed (tree of 478efd8).@objectstack/metadata-protocolvitest: Test Files 371 passed / 9 skipped, Tests 23446 passed / 45 skipped (478efd8). The head d96a1a9 adds one module-top import to the new adopt pin (check:test-source-alias asked for it).@objectstack/specbuild +check:generated: all 14 generated artifacts up to date.Acceptance notes
.changeset/pre/notes (37013, 37130) still carry "of a failed batch row write" and the unqualified re-save prescription in the compiled changelogs; not edited here (see N3 above).database-loader.ts(the write path'splatformRowand the platform withdrawal'staken); they readisPlatformOriginoff the body alone. They were not N5's pair and are left as they are; whether they should ask the shared reader is not measured here.restore only versions the package itself wrotewas the alternative route; not taken, for the reasons above.Verification
Read first:
packages/metadata/src/loaders/database-loader.ts(isPlatformRecordRow,refusePlatformRecordRestore, theregisterRollbackcall),packages/metadata-protocol/src/sys-metadata-repository.ts(restoreVersion's call),packages/metadata-protocol/src/protocol-package-commits.ts(the orphan filter).Two minutes:
pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 src/protocol.platform-mark-rollback.test.ts src/protocol.adopt-orphans-platform-record.test.ts(after building@objectstack/metadata) — expect 12 passed.🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK